<template>
	<view class="person">
		<cu-custom bgColor="bg-gradual-blue"><block slot="backText">个人中心</block></cu-custom>
		<view class="heightbox"></view>
		<view class="personal-center info_box">
			<view class="shouquan-margin" >
				<view class="shouquan padding-lr align-center text-center">
					<view class="shouquan-msg">
						<view class="touxiang">
							<view class="userinfo-avatar">
								<image src="../../static/login/person.png" mode="aspectFit"></image>
							</view>
						</view>
						<view v-if="useInfo!==''" class="loginbtn">{{ useInfo.name }}</view>
					</view>
				</view>
			</view>
			<view class="my-lastdec">
				<view class="radius">
					<view class="my-order" @click="topersonal(1)">
						<text class="iconfont round geren"><!-- <text class="geren"></text> --></text>
						<text>个人中心</text>
						<text class="arrow">></text>
					</view>
					<view class="my-order" @click="open('DialogModal1')">
						<text class=" round tous"><!-- <text class="tous"></text> --></text>
						<text>修改密码</text>
						<text class="arrow">></text>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-modal" :class="modalName == 'DialogModal1' ? 'show' : ''">
			<view class="cu-dialog">
				<view class="bg-white padding justify-center bottom-border">
					<view class="text-center">修改密码</view>
				</view>
				<view class="bg-white cu-modal-middle">
					<view class="flex padding">
						<text class="pwdinput-txt">原密码:</text>
						<input class="pwdinput" type="password" placeholder="请输入原来密码" v-model="form.password" value="" />
					</view>
					<view class="flex padding">
						<text class="pwdinput-txt">新密码:</text>
						<input class="pwdinput" type="password" placeholder="请输入新密码" v-model="form.newPassword" value="" />
					</view>
					<view class="flex padding">
						<text class="pwdinput-txt">确认密码:</text>
						<input class="pwdinput" type="password" placeholder="请确认密码" v-model="form.aPassword" value="" />
					</view>
					<view class="isShowtext">
						{{isShow}}
					</view>
				</view>
				<view class="bg-white border-top">
					<view class="flex">
						<button class="flex-sub bg-white btn-sumit"  @click="submit(1)">取消</button>
						<button class="flex-sub bg-white btn-sumit"  @click="submit(2)">确定</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import chunLeiModal from '@/components/chunLei-modal/chunLei-modal.vue'
	export default {
	components:{
		chunLeiModal
	},
	data() {
		return {
			useInfo: '',
			modalName: null,
			isShow:"",
			form:{
				id:"",
				newPassword:'',
				password:'',
				aPassword:''
			}
		};
	},
	// #ifdef H5
	created() {
		let that=this
		uni.getStorage({
			key:"userInfo",
			success:(res)=>{
				that.useInfo=res.data
			}
		})
	},
	// #endif
	// #ifdef MP-WEIXIN
	onReady() {
		let that=this
		uni.getStorage({
			key:"userInfo",
			success:(res)=>{
				that.useInfo=res.data
			}
		})
	},
	// #endif	
	methods: {
		open(value) {
			this.modalName = 'DialogModal1';
		},
		hideModal1() {
			this.modalName = null;
		},
		topersonal(num) {			
			if(num == 1){
				uni.navigateTo({
					url: '../companycenter/detail'
				});	
			}

		},
		submit(num){
			if(num==1){
				this.hideModal1()
			}else{
				if(this.form.password==""||this.form.newPassword==""||this.form.aPassword==""){
					this.form.password==""?this.isShow="请输入原密码":this.form.newPassword==""?this.isShow="请输入新密码":this.isShow="请输入确认密码"
				}else if(this.form.newPassword!=this.form.aPassword){
					this.isShow="俩次密码不一致"
				}else{
					let that=this
					that.form.id=that.useInfo.id
					uni.request({
					    url:'http://39.100.86.3:8098/system/pwd/enterprise', //接口地址。
					    method: 'GET',
					    data:that.form,
					    header: {
					     'X-Requested-With': 'XMLHttpRequest'
					    },
					    success: (res) => {
							if(res.data=="修改成功"){
								this.hideModal1()
								uni.showToast({
									title:res.data,
									duration:1500,
									icon:'none'
								})	
							}else{
								that.isShow=res.data
							}
					    }
					})
				}
			}
		}
	}
};
</script>

<style scoped lang="scss">
	.info_box{
		margin-top: -85rpx;
		padding: 0 23.52rpx 23.52rpx 23.52rpx;
	}
.position-ab {
	height: 246upx;
}
.position-abr {
	height: 246upx;
}
.heightbox {
	width: 100%;
	height: 105.88rpx;
	background: #5064eb;
}
.person-advitor {
	width: 100%;
	height: 320upx;
}
.padding-lr {
	padding: 0 20upx;
}
.shouquan-margin {
	margin-bottom: 20upx;
	.shouquan {
		.shouquan-msg {
			position: relative;
			z-index: 1;
			height: 157upx;
			background: rgba(255, 255, 255, 1);
			border-radius: 11upx;
			.touxiang {
				position: absolute;
				top: -20upx;
				left: 50%;
				margin-left: -47upx;
				height: 94upx;
				width: 94upx;
				.userinfo-avatar {
					background: #fff;
					overflow: hidden;
					display: block;
					height: 94upx;
					width: 94upx;
					border-radius: 50%;
					border: 2px solid #fff;
					box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
				}
				image {
					width: 100%;
					height: 100%;
				}
			}
			.loginbtn {
				padding-top: 90upx;
				button {
					font-size: 25upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: #5064eb;
					width: 181upx;
					height: 50upx;
					line-height: 50upx;
					background: rgba(255, 255, 255, 1);
					border: 1px solid #5064eb;
					border-radius: 24px;
				}
			}
			// border:1px solid #ccc ;
		}
	}
}

.my-lastdec {
	padding: 10upx 20upx;
	color: #333333;
	.radius {
		border-radius: 11upx;
		.my-order {
			padding: 0 23upx;
			background: #ffffff;
			height: 84upx;
			line-height: 84upx;
			border-bottom: 1px solid #f0f0f0;
			.round {
				vertical-align: middle;
			}
			text:nth-child(2) {
				font-size: 30upx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: rgba(51, 51, 51, 1);
				margin-left: 20upx;
			}
			.arrow {
				float: right;
				font-size: 35upx;
				color: #c7c7cc;
			}
		}
	}
}
// 弹框的样式
.cu-modal{	
	.cu-dialog{
		text-align: left;
		.bottom-border{
			border: 1px solid #CCCCCC;
			font-weight: blod;
		}
		.cu-modal-middle{
			padding: 30upx 50upx;
			.pwdinput-txt{
				display: inline-block;
				width: 30%;
			}
		}
		.border-top{
			border: 1px solid #CCCCCC;
			.btn-sumit{
				height: 100upx;
				line-height: 100upx;		
			}
			.btn-sumit:nth-child(1){
				border-right:1px solid #ccc;
			}
			.btn-sumit:nth-child(2){
				color: #5064eb;
			}
		}
		.isShowtext{
			color: red;
			padding:0 30upx;
			height: 30upx;
			line-height: 30upx;
		}
	}
}
</style>
